# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=monitoring-plugins
pkgver=2.2
pkgrel=14
pkgdesc="Plugins for Icinga, Naemon, Nagios, Shinken, Sensu and other monitoring applications"
url="https://www.monitoring-plugins.org"
arch="all"
license="GPL-3.0-or-later"
options="suid !check" # Tests require interactive output and connecting to various URLs
depends="iputils procps bind-tools"
makedepends="linux-headers libdbi-dev openssl-dev
mariadb-connector-c-dev postgresql-dev perl-dev"
checkdepends="cmd:ksh"
subpackages="$pkgname-doc"
source="https://www.monitoring-plugins.org/download/$pkgname-$pkgver.tar.gz
	mariadb.patch"

prepare() {
	default_prepare
	update_config_guess
	update_config_sub
}

build() {
	 ./configure \
		--prefix=/usr \
		--libexecdir=/usr/lib/monitoring-plugins \
		--with-perl="$(which perl)" \
		--with-ping-command="/bin/ping -n -U -w %d -c %d %s" \
		--with-ping6-command="/bin/ping6 -n -U -w %d -c %d %s" \
		--with-openssl \
		--with-pgsql=/usr \
		--with-dbi \
		--with-mysql \
		--with-ipv6
	make
}

package() {
	make DESTDIR="$pkgdir" install

	for i in ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog \
		FAQ NEWS README REQUIREMENTS SUPPORT THANKS; do
		install -Dm644 $i "$pkgdir"/usr/share/doc/$pkgname/$i
	done
	rm $pkgdir/usr/lib/charset.alias
}

sha512sums="5f8cfa132891d6d96e69bee3f2c26f7d4546f572be6a18f25ea5d9069f162cb2e424361289a5c26bec60d7b63d28a269437fd6f25645903a1c142fdcbbf77f27  monitoring-plugins-2.2.tar.gz
3db122a22012dbd571865023d5542c38541a6667b8e00a08d4180c04117300737f57dbdff3264240cda9f6746419022bace8da06d997b0ade776604c55da9bde  mariadb.patch"
